package ink.lovejinhu.leetcode;

import ink.lovejinhu.common.TreeNode;

/**
 * @author jinhu
 * created 2021-08-02 11:03
 */
public class Solution_0700 {
    public TreeNode searchBST(TreeNode root, int val) {
        this.dfs(root, val);
        return res;
    }

    public TreeNode res = null;

    public void dfs(TreeNode root, int val) {
        if (root == null) {
            return;
        }
        if (root.val == val) {
            res = root;
            return;
        }
        if (root.val < val) {
            dfs(root.right, val);
        }
        if (root.val > val) {
            dfs(root.left, val);
        }
    }
}
